package com.miyu.system.controller.weather;

import com.alibaba.fastjson.JSONObject;
import com.miyu.common.utils.commonUtils.RedisCache;
import com.miyu.system.service.weather.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 天气
 *
 * @author longmy
 * @date 2022/05/17
 */
@RequestMapping("")
@RestController
public class Weather {

    @Autowired
    private WeatherService sts;
    @RequestMapping("tianqiapi")
    public JSONObject queryWeather(@RequestBody JSONObject param) throws Exception {
        String vCity = "";
        if(!param.containsKey("version")){
            param.put("version","v1");
            vCity+="v1";
        }else {
            vCity+=param.getString("version");
        }
        if(!param.containsKey("city")){
            /*默认北京*/
            param.put("city","101010100");
            vCity+="101010100";
        }else {
            vCity+=param.getString("city");
        }
        param.put("vCity",vCity);
        return  sts.queryWeather(param);
    }
}
